home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 1
/
Precision Software Applications Silver Collection Volume One (PSM) (1993).iso
/
games
/
egavga
/
bertha.arj
/
PROGSHOP.C
next >
Wrap
Text File
|
1992-09-29
|
35KB
|
1,219 lines
/**********************************************************************\
* *
* PROGSHOP.C -- copyright 1992 Diana Gruber *
* *
* This is the source code to the Bertha Slot game written by Diana *
* Gruber for The Programmer's Shop. Source code is provided for *
* informational purposes only. All function calls beginning with *
* "fg_" are Fastgraph calls. This program was originally compiled *
* with Microsoft C 6.0 medium model and linked with Fastgraph *
* version 2.10. *
* *
* For more information about Fastgraph, contact The Programmer's Shop. *
* *
\**********************************************************************/
/**********************************************************************\
* *
* To rebuild PROGSHOP.EXE: *
* *
* Let MSC create the header file containing the function prototypes: *
* cl /Zg progshop.c > progshop.h *
* *
* Compile and link with Fastgraph: *
* cl /c /W3 /AM progshop.c *
* link /E progshop,progshop.exe,NUL.MAP,fgm; *
* *
\**********************************************************************/
#include "progshop.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fastgraf.h>
#define FALSE 0
#define TRUE 1
#define ESC 27
#define SPACE 32
#define ENTER 13
#define INS 82
#define ZERO 48
int hidden;
int visual;
int clockspeed;
int seed;
int old_mode;
int total;
int ncoins;
int npulls;
int num[3];
int bar0,bar1,bar2;
int sym_0[3];
int sym_1[3];
int sym_2[3];
int jackpot = FALSE;
char triple_bar[76];
int reel0[] = {4,5,3,0,4,
5,6,5,4,5,
1,5,6,5,3,
5,2,5,4,5};
int reel1[] = {4,1,6,3,6,
0,5,6,2,6,
4,6,1,3,6,
2,6,5,2,6};
int reel2[] = {3,4,5,4,3,
4,3,0,4,3,
5,3,1,4,3,
4,3,2,3,4};
int tri_x[] = {215,247,279,
215,247,279,
215,247,279,
318,382,350,
318,382};
int tri_y[] = {75,75,75,
97,97,97,
53,53,53,
53,97,75,
97,53};
/**********************************************************************\
* *
* main *
* *
\**********************************************************************/
int colors[] = {0,1,16,3,4,5,38,7,56,6,2,32,52,59,62,63};
void main()
{
unsigned char key, aux;
if (fg_egacheck() != 4)
{
printf("\n");
printf("This program requires an EGA with 256K \n");
printf("and an Enhanced Color Display (ECD).\n\n");
printf("If an EGA is present, it must be the active adapter.\n");
exit(0);
}
init_graphics(16);
fg_palettes(colors);
fg_setpage(hidden);
fg_move(0,349);
fg_dispfile("progshp0.ppr",640,1);
fg_copypage(hidden,visual);
fg_setpage(hidden);
fg_move(0,349);
fg_dispfile("progshp1.ppr",640,1);
fg_setcolor(0);
fg_rect(340,380,146,150);
fg_rect(340,380,166,170);
fg_rect(340,380,186,190);
/* wait for a key press to get past the intro screen */
fg_getkey(&key,&aux);
/* draw the background and the floor */
fg_setpage(visual);
fg_setcolor(1);
fg_rect(0,639,0,349);
fg_setcolor(4);
fg_rect(0,639,292,349);
fg_setcolor(0);
fg_rect(0,639,291,291);
/* copy the slot machine and the girl to the visual page */
fg_palette(13,61);
fg_transfer(144,487,0,349,144,349,hidden,visual);
fg_transfer(488,639,0,259,456,349,hidden,visual);
fg_tcmask(2);
/* pick up the triple bar bitmap */
get_triple_bar();
fg_setpage(hidden);
fg_move(tri_x[10],tri_y[10]);
fg_drawmap(triple_bar,4,19);
npulls = 0;
spin_reels();
}
/**********************************************************************\
* *
* clear_triple_bars -- unhighlight the bars at top of machine *
* *
\**********************************************************************/
void clear_triple_bars()
{
register int i;
int x,y;
fg_setpage(visual);
for (i = 0; i < 14; i++)
{
x = tri_x[i];
y = tri_y[i];
fg_move(x,y);
fg_setcolor(0);
fg_drawmap(triple_bar,4,19);
fg_setcolor(4);
fg_rect(x+10,x+11,y-13,y);
if (i == 10)
{
fg_setpage(hidden);
fg_move(x,y);
fg_setcolor(0);
fg_drawmap(triple_bar,4,19);
fg_setcolor(4);
fg_rect(x+10,x+11,y-13,y);
fg_setpage(visual);
}
}
}
/**********************************************************************\
* *
* final_message -- say goodbye, Bertha *
* *
\**********************************************************************/
char *exit_text[] = {
"■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■",
" ",
" ",
" ",
" ┌─────────────────────────────────────────────────────────────┐ ",
" │ │ ",
" │ Don't gamble with programming tools! For all your │ ",
" │ programming needs, including Fastgraph from Ted Gruber │ ",
" │ Software, contact The Programmer's Shop. │ ",
" │ │ ",
" │ The Programmer's Shop │ ",
" │ 90 Industrial Park Road │ ",
" │ Hingham, MA 02043 │ ",
" │ 1-800-421-8006 │ ",
" │ │ ",
" │ This copy of Bertha Slot not for redistribution. │ ",
" └─────────────────────────────────────────────────────────────┘ ",
" ",
" ",
" ",
"■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■"
};
void final_message()
{
register int i;
int row;
fg_setattr(15,1,0);
for (i = 0; i < 21; i++)
{
fg_locate(i,0);
fg_text(exit_text[i],80);
}
/* lights at top and bottom */
fg_locate(0,0);
for (i = 0; i < 80; i+=5)
{
fg_setattr(2,1,0);
fg_chgattr(1);
fg_setattr(3,1,0);
fg_chgattr(1);
fg_setattr(10,1,0);
fg_chgattr(1);
fg_setattr(11,1,1);
fg_chgattr(1);
fg_setattr(9,1,0);
fg_chgattr(1);
}
fg_locate(20,0);
for (i = 0; i < 80; i+=5)
{
fg_setattr(9,1,0);
fg_chgattr(1);
fg_setattr(11,1,1);
fg_chgattr(1);
fg_setattr(10,1,0);
fg_chgattr(1);
fg_setattr(3,1,0);
fg_chgattr(1);
fg_setattr(2,1,0);
fg_chgattr(1);
}
fg_setattr(1,7,0);
for (row = 5; row <= 9; row++)
{
fg_locate(row,7);
fg_chgattr(65);
}
fg_locate(15,7);
fg_chgattr(65);
fg_setattr(0,7,0);
for (row = 10; row <= 14; row++)
{
fg_locate(row,7);
fg_chgattr(65);
}
/* red outline */
fg_setattr(4,7,0);
fg_locate(4,7);
fg_chgattr(65);
fg_locate(16,7);
fg_chgattr(65);
for (row = 5; row <= 15; row++)
{
fg_locate(row,8);
fg_chgattr(1);
fg_locate(row,70);
fg_chgattr(1);
}
/* 'Don't Gamble' */
fg_setattr(4,7,0);
fg_locate(6,12);
fg_chgattr(36);
/* The Programmer's Shop */
fg_setattr(10,7,0);
fg_locate(8,30);
fg_chgattr(22);
/* Fastgraph */
fg_setattr(14,7,0);
fg_locate(7,41);
fg_chgattr(9);
fg_locate(21,0);
return;
}
/**********************************************************************\
* *
* flushkey -- flush out the keystroke buffer *
* *
\**********************************************************************/
void flushkey()
{
unsigned char key,aux;
do
fg_intkey(&key,&aux);
while (key+aux > 0);
}
/**********************************************************************\
* *
* getseed -- get a seed for the random number generator *
* *
\**********************************************************************/
void getseed()
{
seed = (int)(fg_getclock() & 0x7FFF);
}
/**********************************************************************\
* *
* get_string_x -- return position of number string *
* *
\**********************************************************************/
get_string_x(num)
int num;
{
if (num < 0)
{
if (num <= -10000)
return(340);
else if (num <= -1000)
return(343);
else if (num <= -100)
return(347);
else if (num <= -10)
return(351);
else
return(354);
}
else if (num < 10)
return(358);
else if (num < 100)
return(354);
else if (num < 1000)
return(351);
else if (num < 10000)
return(347);
else
return(343);
}
/**********************************************************************\
* *
* getsym -- return the nth symbol on reel i *
* *
\**********************************************************************/
getsym(i,n)
int i,n;
{
register int sym;
switch(i)
{
case 0:
sym = reel0[n];
break;
case 1:
sym = reel1[n];
break;
case 2:
sym = reel2[n];
break;
}
return(sym);
}
/**********************************************************************\
* *
* get_triple_bar -- pick up a bitmap of Prog Shop logo *
* *
\**********************************************************************/
void get_triple_bar()
{
fg_setpage(hidden);
fg_setcolor(0);
fg_move(306,148);
fg_getmap(triple_bar,4,19);
}
/**********************************************************************\
* *
* init_graphics -- initialize the graphics environment *
* *
\**********************************************************************/
void init_graphics(mode)
int mode;
{
/* find out what the old video mode is */
old_mode = fg_getmode();
/* initialize the new video mode */
fg_setmode(mode);
/* set up visual and hidden pages */
fg_setpage(0);
fg_setvpage(0);
fg_sethpage(1);
visual = 0;
hidden = 1;
getseed();
clockspeed = fg_measure();
/* turn off the numlock key */
fg_setnum(0);
}
/**********************************************************************\
* *
* insert_sound -- noise when coins are inserted *
* *
\**********************************************************************/
void insert_sound()
{
if (!fg_numlock())
{
fg_waitfor(1);
fg_sound(900,1);
}
}
/**********************************************************************\
* *
* irandom -- generate a random number *
* *
\**********************************************************************/
irandom(min,max)
int min;
int max;
{
register int temp;
temp = seed ^ (seed >> 7);
seed = ((temp << 8) ^ temp) & 0x7FFF;
return((seed % (max-min+1)) + min);
}
/**********************************************************************\
* *
* payout -- calculate return the payout on one of 5 lines *
* *
\**********************************************************************/
payout(j)
int j;
/* 0 <= num[i] <= 19 is top position on ith reel */
{
int sym0,sym1,sym2;
int amount;
bar0 = FALSE;
bar1 = FALSE;
bar2 = FALSE;
switch(j)
{
case 1:
sym0 = sym_1[0];
sym1 = sym_1[1];
sym2 = sym_1[2];
break;
case 2:
sym0 = sym_2[0];
sym1 = sym_2[1];
sym2 = sym_2[2];
break;
case 3:
sym0 = sym_0[0];
sym1 = sym_0[1];
sym2 = sym_0[2];
break;
case 4:
sym0 = sym_0[0];
sym1 = sym_1[1];
sym2 = sym_2[2];
break;
case 5:
sym0 = sym_2[0];
sym1 = sym_1[1];
sym2 = sym_0[2];
break;
}
if (j == 5 && sym0 == 0 && sym1 == 0 && sym2 == 0)
return(2000);
if (sym0 == 0 || sym0 == 1 || sym0 == 2) bar0 = TRUE;
if (sym1 == 0 || sym1 == 1 || sym1 == 2) bar1 = TRUE;
if (sym2 == 0 || sym2 == 1 || sym2 == 2) bar2 = TRUE;
amount = 0;
/* three symbols match */
if (sym0 == sym1 && sym1 == sym2)
{
switch(sym0)
{
case 0: /* 3 bar */
amount = 200;
jackpot = TRUE;
break;
case 1: /* 2 bar */
amount = 100;
jackpot = TRUE;
break;
case 2: /* 1 bar */
amount = 50;
jackpot = TRUE;
break;
case 3: /* bells */
amount = 18;
break;
case 4: /* plums */
amount = 14;
break;
case 5: /* oranges */
amount = 10;
break;
}
}
/* any bars */
else if (bar0 && bar1 && bar2)
{
amount = 20;
jackpot = TRUE;
}
/* 2 bells and 1 bar */
else if (sym0 == 3 && sym1 == 3 && bar2)
amount = 18;
/* 2 plums and 1 bar */
else if (sym0 == 4 && sym1 == 4 && bar2)
amount = 14;
/* 2 oranges and 1 bar */
else if (sym0 == 5 && sym1 == 5 && bar2)
amount = 10;
/* 2 cherries */
else if (sym0 == 6 && sym1 == 6)
amount = 5;
/* 1 cherry */
else if (sym0 == 6)
amount = 2;
return(amount);
}
/**********************************************************************\
* *
* payout_sound -- noise for coin payout ("dink! dink! dink") *
* *
\**********************************************************************/
void payout_sound()
{
fg_waitfor(1);
if (!fg_numlock())
fg_sound(1500,1);
}
/**********************************************************************\
* *
* put_string -- put 5X5 bitmapped text at an x,y position *
* *
\**********************************************************************/
char chars[41][5] = {
-120, -8,-120, 80, 32, /* A */
-16,-120, -16,-120, -16, /* B */
120,-128,-128,-128, 120, /* C */
-16,-120,-120,-120, -16, /* D */
-8,-128, -16,-128, -8, /* E */
-128,-128, -16,-128, -16, /* F */
112,-120,-104,-128, 120, /* G */
-120,-120, -8,-120,-120, /* H */
112, 32, 32, 32, 112, /* I */
96,-112, 16, 16, 56, /* J */
-120,-112, -32,-112,-120, /* K */
-8,-128,-128,-128,-128, /* L */
-120, -88, -88, -40,-120, /* M */
-120,-104, -88, -56,-120, /* N */
112,-120,-120,-120, 112, /* O */
-128,-128, -16,-120, -16, /* P */
120, -88,-120,-120, 112, /* Q */
-112, -96, -16,-120, -16, /* R */
-16, 8, 112,-128, 120, /* S */
32, 32, 32, 32, -8, /* T */
112,-120,-120,-120,-120, /* U */
32, 80,-120,-120,-120, /* V */
-120, -40, -88, -88,-120, /* W */
-120, 80, 32, 80,-120, /* X */
32, 32, 32, 80,-120, /* Y */
-8, 64, 32, 16, -8, /* Z */
112,-120,-120,-120, 112, /* O */
112, 32, 32, 96, 32, /* 1 */
-16, 64, 32,-112, 96, /* 2 */
-32, 16, 96, 16, -32, /* 3 */
16, 16, -16,-112,-112, /* 4 */
112, 8, -16,-128, -8, /* 5 */
112,-120, -16,-128, 112, /* 6 */
64, 64, 32, 16, -8, /* 7 */
112,-120, 112,-120, 112, /* 8 */
16, 8, 120,-120, 112, /* 9 */
128, 64, 0, 0, 0, /* , */
64, 0, 0, 0, 0, /* . */
0, 0, 112, 0, 0, /* - */
64, 0, 0, 64, 0}; /* : */
void put_string(string,x,y,space)
char string[];
int x;
int y;
int space;
{
register int i, nchar;
int blank;
char ch;
nchar = strlen(string);
for (i = 0; i < nchar; i++)
{
blank = FALSE;
ch = string[i];
if (ch >= 65 && ch <= 90) /* upper case */
ch -= 65;
else if (ch >= 97 && ch <= 122) /* lower case */
ch -= 97;
else if (ch >= 48 && ch <= 57) /* numbers */
ch -= 22;
else if (ch == 44) /* comma */
ch = 36;
else if (ch == 46) /* period */
ch = 37;
else if (ch == 45) /* minus */
ch = 38;
else if (ch == 58) /* colon */
ch = 39;
else
blank = TRUE;
fg_move(x,y);
if (!blank) fg_drawmap(&chars[ch][0],1,5);
x += space;
}
}
/**********************************************************************\
* *
* put_triple_bars -- highlight bars at top as coins are inserted *
* *
\**********************************************************************/
void put_triple_bars(ncoins)
int ncoins;
{
register int i;
int i1,i2;
int x,y;
switch(ncoins)
{
case(1):
i1 = 0;
i2 = 2;
break;
case(2):
i1 = 3;
i2 = 5;
break;
case(3):
i1 = 6;
i2 = 8;
break;
case(4):
i1 = 9;
i2 = 11;
break;
case(5):
i1 = 0;
i2 = 13;
break;
}
for (i = i1; i <= i2; i++)
{
x = tri_x[i];
y = tri_y[i];
fg_move(x,y);
fg_setcolor(8);
fg_drawmap(triple_bar,4,19);
fg_setcolor(12);
fg_rect(x+10,x+11,y-13,y);
if (i == 10)
{
fg_setpage(hidden);
fg_move(x,y);
fg_setcolor(8);
fg_drawmap(triple_bar,4,19);
fg_setcolor(12);
fg_rect(x+10,x+11,y-13,y);
fg_setpage(visual);
}
}
}
/**********************************************************************\
* *
* quit_graphics -- return the computer to its original state *
* *
\**********************************************************************/
void quit_graphics()
{
/* make sure the speaker is off */
fg_hush();
/* set the mode to whatever it was originally */
fg_setmode(old_mode);
fg_reset();
final_message();
exit(0);
}
/**********************************************************************\
* *
* random_song -- play a nice song while the reels are spinning *
* *
\**********************************************************************/
void random_song(i)
int i;
{
switch(i)
{
case(0):
fg_musicb("O4 T130 L16 BA L8 G L16 GAGD O- B O+ CDED O- B O+ L8 D L16 GA L8 BB L16 BAGA L8 BAA$",1);
break;
case(1):
fg_musicb("O4 T120 L8 D L16 GBAG L8 EEDD G. L16 P L8 AABB L16 ABAG L8 ED$",1);
break;
case(2):
fg_musicb("O4 T240 L8 DE L4 F#F#D L8 DE L4 F#F#D L8 DE L8 F#F#F#F#GGF#F# L2 E $",1);
break;
case(3):
fg_musicb("O4 T160 L4 AAA. L16 G#. L32 A L8 A#AG#AFCFA L4 O+ CCC. L16 O- B O+ C L8 DC O- L16 BB O+ L8 C O- ACDF$",1);
break;
case(4):
fg_musicb("O4 T140 L8 EEC#EF#EC#PC# L4O-BO+ L8PC# L4O-BO+L8EEEC#EF#EC#P L4O-BO+L8C#O-BO+ L4O-A$",1);
break;
case(5):
fg_musicb("O4 T250 L4 O- G L4 G O+ CD L2 E L8 EE L4 F O- AA O+ L2 D O- L4 GGB O+ C L4 DE. L8 D L4 DC O- A L2 G$",1);
break;
}
}
/**********************************************************************\
* *
* spin_reels -- pull the handle and watch the reels go around *
* *
\**********************************************************************/
void spin_reels()
{
register int i,j;
unsigned char key,aux;
int skip;
int stall_time;
int sym;
int bottom[3];
int top[3];
int reel_num = 0;
int x,y;
int win_amount;
int counter[3];
char string[7];
int face_count;
int face_target;
int hip_count;
int hip_target;
static int old_song = 0;
int song_no;
static int stop[] = {0,0,0};
static int stopped[] = {0,0,0};
static int xmin[] = {208,256,304};
static int xmax[] = {239,287,335};
static int ymin = 129;
static int ymax = 200;
static int even = TRUE;
static int x1[] = {208,208,304,304,256,208,256};
static int x2[] = {239,239,335,335,287,239,287};
static int y1[] = {177,129,177,153,129,153,177};
static int y2[] = {200,152,200,176,152,176,200};
static int siren[] = {750,1,700,1,650,1,600,1,550,1,500,1,450,1,400,1,
450,1,500,1,550,1,600,1,650,1,700,0,0};
static int handle[] = {420,5,415,4,410,3,400,2,390,1,
380,1,370,1,360,1,350,1,340,1,330,1,
320,1,310,1,300,1,290,1,280,1,270,1,
320,1,350,1,380,1,420,1,450,1,500,1,
550,1,0,0};
stall_time = clockspeed/8;
fg_setpage(visual);
fg_setcolor(15);
for (i = 0; i < 3; i++)
{
num[i] = 0;
bottom[i] = y2[getsym(i,0)];
}
while(1)
{
/* initialize stuff for the spin */
for (i = 0; i<3; i++)
{
stop[i] = FALSE;
stopped[i] = FALSE;
}
skip = 8;
reel_num = 0;
clear_triple_bars();
/* get coins */
ncoins = 0;
key = 0;
face_count = 0;
face_target = irandom(50,200);
hip_count = 0;
hip_target = irandom(50,100);
while (key != ENTER && ncoins < 5)
{
while(1)
{
fg_waitfor(2);
fg_intkey(&key,&aux);
if (key+aux > 0) break;
/* make kissy-faces */
face_count++;
if (face_count == face_target)
{
fg_transfer(488,543,261,307,528,137,hidden,visual);
}
else if (face_count >= face_target+2)
{
fg_transfer(560,615,1,47,528,137,hidden,visual);
face_count = 0;
face_target = irandom(100,300);
}
/* swish the hips */
hip_count++;
if (hip_count == hip_target)
fg_transfer(544,607,260,349,528,279,hidden,visual);
else if (hip_count == hip_target+2 && hip_target > 150)
fg_transfer(488,639,0,259,456,349,hidden,visual);
else if (hip_count == hip_target+4 && hip_target > 150)
fg_transfer(544,607,260,349,528,279,hidden,visual);
else if (hip_count >= hip_target+6)
{
fg_transfer(488,639,0,259,456,349,hidden,visual);
hip_target = irandom(5,300);
hip_count = 0;
}
}
if (key == ESC)
quit_graphics();
else if (key == SPACE)
{
insert_sound();
ncoins++;
sprintf(string,"%-6d\0",ncoins);
fg_setcolor(4);
fg_rect(428,432,58,62);
fg_setcolor(14);
put_string(string,428,62,7);
/* record total */
total--;
x = get_string_x(total);
sprintf(string,"%-6d\0",total);
fg_setcolor(0);
fg_rect(340,380,166,170);
fg_setcolor(14);
put_string(string,x,170,7);
if (ncoins == 1) clear_triple_bars();
put_triple_bars(ncoins);
}
/* insert key for 5 coins */
else if (key == ZERO || aux == INS)
{
ncoins = 5;
sprintf(string,"%-6d\0",ncoins);
fg_setcolor(4);
fg_rect(428,432,58,62);
fg_setcolor(14);
put_string(string,428,62,7);
/* record total */
total -= 5;
x = get_string_x(total);
sprintf(string,"%-6d\0",total);
fg_setcolor(0);
fg_rect(340,380,166,170);
fg_setcolor(14);
put_string(string,x,170,7);
put_triple_bars(5);
break;
}
}
/* must play at least one coin */
if (ncoins == 0)
{
insert_sound();
ncoins = 1;
sprintf(string,"%-6d\0",ncoins);
fg_setcolor(4);
fg_rect(428,432,58,62);
fg_setcolor(14);
put_string(string,428,62,7);
/* record total */
total--;
x = get_string_x(total);
sprintf(string,"%-6d\0",total);
fg_setcolor(0);
fg_rect(340,380,166,170);
fg_setcolor(14);
put_string(string,x,170,7);
put_triple_bars(ncoins);
}
/* clear the "you win" row */
fg_setcolor(0);
fg_rect(340,380,146,150);
if (!fg_numlock()) fg_sounds(handle,1);
/* restore girl's face */
fg_transfer(560,615,1,47,528,137,hidden,visual);
/* pull the handle */
fg_setpage(hidden);
fg_setcolor(1);
fg_rect(0,143,263,393);
fg_setpage(visual);
fg_transfer(400,487,90,220,0,393,hidden,hidden);
fg_tcxfer(0,111,0,129,32,393,hidden,hidden);
fg_transfer(0,143,263,393,400,220,hidden,visual);
fg_waitfor(1);
fg_setpage(hidden);
fg_setcolor(1);
fg_rect(0,143,263,393);
fg_setpage(visual);
fg_transfer(400,487,90,220,0,393,hidden,hidden);
fg_tcxfer(0,143,131,261,0,393,hidden,hidden);
fg_transfer(0,143,263,393,400,220,hidden,visual);
fg_waitfor(2);
fg_transfer(400,487,64,349,400,349,hidden,visual);
fg_transfer(488,639,0,259,456,349,hidden,visual);
while (fg_playing()) fg_waitfor(1);
/* spin the three reels */
do
song_no = irandom(0,5);
while (song_no == old_song);
if (song_no < 3)
{
counter[0] = irandom(30,60);
counter[1] = counter[0] + irandom(30,60);
counter[2] = counter[1] + irandom(30,60);
}
else
{
counter[0] = irandom(60,90);
counter[1] = counter[0] + irandom(60,90);
counter[2] = counter[1] + irandom(60,90);
}
if (!fg_numlock()) random_song(song_no);
old_song = song_no;
while(1)
{
flushkey();
for (i = 0; i < 3; i++)
{
fg_stall(stall_time);
if (counter[i] > 0)
counter[i]--;
else
stop[i] = TRUE;
if (!stopped[i])
{
sym = getsym(i,num[i]);
bottom[i] = bottom[i] - skip;
if (bottom[i] <= y1[sym])
{
/* stop the reel at the bottom of a symbol */
if (stop[i])
{
stopped[i] = TRUE;
sym_0[i] = sym;
/* get the 2nd and third symbol on the reel */
j = num[i] - 1;
if (j < 0) j = 19;
sym_1[i] = getsym(i,j);
j --;
if (j < 0) j = 19;
sym_2[i] = getsym(i,j);
}
/* or else get the next symbol on the reel */
else
{
num[i]++;
if (num[i] >= 20) num[i] = 0;
sym = getsym(i,num[i]);
bottom[i] = y2[sym];
}
}
}
top[i] = bottom[i] - skip + 1;
y = ymin + skip - 1;
if (!stopped[i])
{
fg_setcolor(15);
fg_scroll(xmin[i],xmax[i],ymin,ymax-skip,skip,1);
fg_transfer(x1[sym],x2[sym],top[i],bottom[i],xmin[i],y,hidden,visual);
}
}
if (stopped[0])
skip = 6;
else if (stopped[1])
skip = 4;
if (stopped[0] && stopped[1] && stopped [2])
{
flushkey();
while (fg_playing()) fg_waitfor(1);
/* record win amount */
win_amount = 0;
for (j = 1; j <= ncoins; j++)
win_amount = win_amount + payout(j);
if (win_amount == 0)
{
fg_setcolor(0);
fg_rect(340,380,146,150);
fg_setcolor(14);
put_string("0",358,150,7);
}
else
{
if (jackpot && !fg_numlock()) fg_sounds(siren,-1);
for (j = 1; j <= win_amount; j++)
{
if (!jackpot) payout_sound();
x = get_string_x(j);
sprintf(string,"%-6d\0",j);
fg_setcolor(0);
fg_rect(340,380,146,150);
fg_setcolor(14);
put_string(string,x,150,7);
/* record total */
total ++;
x = get_string_x(total);
sprintf(string,"%-6d\0",total);
fg_setcolor(0);
fg_rect(340,380,166,170);
fg_setcolor(14);
put_string(string,x,170,7);
if (jackpot)
{
fg_waitfor(4);
if (even)
fg_palette(11,52);
else
fg_palette(11,32);
even = !even;
}
}
}
/* record the number of pulls */
npulls++;
x = get_string_x(npulls);
sprintf(string,"%-6d\0",npulls);
fg_setcolor(0);
fg_rect(340,380,186,190);
fg_setcolor(14);
put_string(string,x,190,7);
fg_hush();
jackpot = FALSE;
even = TRUE;
fg_palette(11,32);
break;
}
}
}
}